package com.easy.controller;

import com.easy.bean.User;
import com.easy.util.SYS;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("shopping")
public class ShoppingPageController {
    @RequestMapping("index")
    public String index(){
        return "shopping/index.html";
    }

    @RequestMapping("login")
    public String login(){
        return "shopping/login.html";
    }

    @RequestMapping("cart")
    public String cart(){
        return "shopping/cart.html";
    }


    @RequestMapping("list")
    public String list(Integer categoryid,String keywords,Model model){
        model.addAttribute("categoryid",categoryid);
        model.addAttribute("keywords",keywords);
        return "shopping/list.html";
    }

    @RequestMapping("product")
    public String product(Integer id, Model model){
        model.addAttribute("id",id);
        return "shopping/product.html";
    }
    @RequestMapping("userinfo")
    public String userinfo(HttpSession session){
        User user=new User();
        user.setId(1);
        session.setAttribute(SYS.SHOPPING_LOGIN_USER,user);
        return "shopping/userinfo.html";
    }
    @RequestMapping("settlement")
    public String settlement(String productids,String counts,Model model){
        model.addAttribute("productids",productids);
        model.addAttribute("counts",counts);
        return "shopping/settlement.html";
    }
    @RequestMapping("register")
    public String register(){
        return "shopping/register.html";
    }

    @RequestMapping("payment")
    public String payment(Integer id,Model model){
        model.addAttribute("id",id);
        return "shopping/payment.html";
    }

}
